package com.itheima.controller;

import com.itheima.common.Code;
import com.itheima.common.Result;
import com.itheima.dto.OrderFormDto;
import com.itheima.pojo.OrderForm;
import com.itheima.service.OrderFormService;
import com.itheima.vo.DishVo;
import com.itheima.vo.OrderFormVo;
import com.itheima.vo.PagingQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author :WuJunJie
 * packageName :com.itheima.controller
 * fileName :Order
 * creationTime :2022-11-28 10:48
 */
@RestController
@RequestMapping("order")
public class OrderFormController {
    @Autowired
    private OrderFormService orderFormService;
    @PostMapping("submit")
    public Result insertOrder(@RequestBody OrderFormDto orderFormDto){
        Boolean insert=orderFormService.insertOrder(orderFormDto);
        if (insert){
        return Result.success();
        }
        return Result.error(Code.Forbidden.getCode());
    }
    @GetMapping("userPage")
    public Result selectPage(@RequestParam("page")Integer page,
                            @RequestParam("pageSize")Integer pageSize){
        PagingQueryVo<OrderFormVo> pagingQueryVo=orderFormService.userSelectPage(page,pageSize);
        return Result.success(pagingQueryVo);
    }


}
